package com.uetoken.cn.adapter;

import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.uetoken.cn.R;
import com.uetoken.cn.bean.BindAccountBean;
import com.uetoken.cn.bean.MeItemBean;
import com.uetoken.cn.utils.GlideApp;

import java.util.List;

/**
 * author : hejunming
 * e-mail : 925379434@qq.com
 * date   : 2018/10/30 17:33
 */
public class BindAccountAdapter extends BaseQuickAdapter<BindAccountBean.DataBean, BaseViewHolder> {

    //1-QQ、2-微信、3-微博、4-Pcn、5-优谷
    private int[] iconInt = new int[]{R.drawable.bind_qq_icon, R.drawable.bind_wechat_icon,
            R.drawable.bind_sina_icon, R.drawable.bind_pcn_icon, R.drawable.bind_yougu_icon};
    private int[] appNameStr = new int[]{R.string.str_qq, R.string.str_wechat,
            R.string.str_sina, R.string.str_pcn, R.string.str_yg};

    public BindAccountAdapter(int layoutResId, @Nullable List<BindAccountBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BindAccountBean.DataBean item) {
        /**
         * opentype (integer, optional): 绑定的第三方账号类型：1-QQ、2-微信、3-微博、4-Pcn、5-优谷 ,
         * status (integer, optional): 账号绑定的状态：0-未绑定、1-绑定
         */
        int opentype = item.getOpentype();
        int status = item.getStatus();
        String statusText;
        GlideApp.with(mContext).load(iconInt[opentype - 1]).into((ImageView) helper.getView(R.id.iv_item_me));
        helper.setText(R.id.tv_item_me, mContext.getResources().getString(appNameStr[opentype - 1]));
        if (opentype == 3) {
            helper.setGone(R.id.ll_item_me, false);
        }
        if (status == 0) {
            statusText = mContext.getResources().getString(R.string.str_not_bind);
            helper.setTextColor(R.id.tv_item_me_other_info, ContextCompat.getColor(mContext, R.color.app_color_common_gray));
        } else {
            statusText = mContext.getResources().getString(R.string.str_unbundle);
            helper.setTextColor(R.id.tv_item_me_other_info, ContextCompat.getColor(mContext, R.color.app_color_common_black));
        }
        helper.setText(R.id.tv_item_me_other_info, statusText);
    }
}
